import 'package:leader_doctor_flutter/common/data/app.dart';
import 'package:leader_doctor_flutter/common/utils/log_utils.dart';
import 'package:leader_doctor_flutter/common/utils/meeting_utils.dart';
import 'package:leader_doctor_flutter/common/utils/string_utils.dart';
import 'package:leader_doctor_flutter/model/event/file_event.dart';
import 'package:leader_doctor_flutter/plugins/plugins_messages.g.dart';

import '../model/event/event.dart';

/// @Author lixiaobin
/// @Date 2023/12/5
/// @Description
class PigeonApiImplementation extends FlutterInterface {
  @override
  void meetingLogout() {
    MeetingUtils.instance.logout();
  }

  @override
  void cancelMeetingMinimizationWindow() {
    Log.d('结束最小化****');
    MeetingUtils.instance.fullCurrentMeeting();
  }

  @override
  void onFileSelect(List<FileInfo?> fileList) {
    Log.d("onFileSelect $fileList");
    App.instance.eventBus.fire(FileEvent(fileList));
  }

  @override
  void onResume(String tag) {
    App.instance.eventBus.fire(BaseEvent('bank_card_manage'));
  }

  @override
  int findMeetingStatus(String mdtId) {
    var id = MeetingUtils.instance.mdtId;
    var info = MeetingUtils.instance.getCurrentMeetingInfo();
    if (info != null) {
      if (id != mdtId) {
        NativeInterface().toast('您已在其他会议中');
        return -1;
      } else if (id == mdtId) {
        return 1;
      }
    }
    return 0;
  }

  @override
  void setAvatar() {
    Log.d('setAvatar');
    App.instance.eventBus.fire(BaseEvent('set_avatar_succeed'));
  }
}
